package com.mxl.dao.cashorder.impl;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.mxl.dao.cashorder.model.ExchargeRule;
import com.mxl.datebase.orm.hibernate.BaseDaoSupport;

public class ExchargeRuleDaoImpl extends BaseDaoSupport<ExchargeRule, Long> {
	public ExchargeRule getRate(String memberCode, int bossType) {
		List<Criterion> criterions = new ArrayList<Criterion>();
		criterions.add(Restrictions.eq("memberCode", memberCode));
		criterions.add(Restrictions.eq("autochargeFlag", 1));
		criterions.add(Restrictions.eq("bossType", bossType));
		List<ExchargeRule> rules = this.find(new Order[] { Order
				.desc("effectDate") }, criterions.toArray(new Criterion[criterions.size()]));
		return rules != null && !rules.isEmpty() ? rules.get(0) : null;
	}
}
